const TOKEN = "token";
const USER_INFO = "ownerApp_userInfo";
const CURRENT_C_INFO = "ownerApp_currentInfo";
const LINKINPARAMETERS = "ownerApp_linkInParameters";
const LOGIN_INFO = "Manage_loginInfo";

export function getStorageSync(_key) {
  let _value = uni.getStorageSync(_key);
  return _value;
}

export function setStorageSync(_key, _value) {
  uni.setStorageSync(_key, _value);
}

export function saveUserInfo(_owner) {
  uni.setStorageSync(USER_INFO, JSON.stringify(_owner));
}

export function saveLoginInfo(obj) {
  uni.setStorageSync(LOGIN_INFO, JSON.stringify(obj));
}

export function getLoginInfo() {
  let loginInfo = uni.getStorageSync(LOGIN_INFO);
  return loginInfo && JSON.parse(loginInfo) || {};
}

export function getUserInfo() {
  let _userInfo = uni.getStorageSync(USER_INFO);
  return _userInfo && JSON.parse(_userInfo) || {};
}

export function saveCurrentRoom(_room) {
  uni.setStorageSync(CURRENT_C_INFO, JSON.stringify(_room));
}

export function getCurrentRoom() {
  let info = uni.getStorageSync(CURRENT_C_INFO);
  return info && JSON.parse(info) || {};
}


export function saveUserToken(_token) {
  uni.setStorageSync(TOKEN, _token);
}

export function getToken() {
  return uni.getStorageSync(TOKEN)
}

export function saveLinkInParameters(_info) {
  uni.setStorageSync(LINKINPARAMETERS, JSON.stringify(_info));
}

export function getLinkInParameters() {
  let _userInfo = uni.getStorageSync(LINKINPARAMETERS);
  return _userInfo && JSON.parse(_userInfo) || {};
}
